/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foxmob.mlts.view.setter;

import javax.swing.JTextArea;

/**
 *
 * @author Lunayo
 */
public class FillInTheBlankSetterPanel extends javax.swing.JPanel {

    /**
     * Creates new form FillInTheBlankSetter
     */
    public FillInTheBlankSetterPanel() {
        initComponents();
    }
    
    public void setQuestionText(String questionText) {
        this.questionText.setText(questionText);
    }
    
    public String getQuestionText() {
        return this.questionText.getText();
    }
    
    public void setCorrectAnswer(String[] correctAnswer) {
        StringBuilder sb = new StringBuilder();
        for (String pos : correctAnswer) {
            sb.append(pos).append("\n");
        }
        this.correctAnswerText.setText(sb.toString());
    }
    
    public String[] getCorrectAnswer() {
        String lines[] = 
                this.correctAnswerText.getText().split("\\r?\\n");
        return lines;
    }
    
    public JTextArea getCorrectAnswerTextArea() {
        return this.correctAnswerText;
    }
    
    public JTextArea getQuestionTextArea() {
        return this.questionText;
    }
    
    public void resetInputComponent() {
        this.correctAnswerText.setText("");
        this.questionText.setText("");
    }
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        questionLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        questionText = new javax.swing.JTextArea();
        correctAnswerLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        correctAnswerText = new javax.swing.JTextArea();

        questionLabel.setText("Question :");

        questionText.setColumns(20);
        questionText.setRows(5);
        jScrollPane1.setViewportView(questionText);

        correctAnswerLabel.setText("Correct Answer :");

        correctAnswerText.setColumns(20);
        correctAnswerText.setRows(5);
        jScrollPane2.setViewportView(correctAnswerText);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(questionLabel)
                            .add(correctAnswerLabel))
                        .add(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(questionLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 84, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(correctAnswerLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(16, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel correctAnswerLabel;
    private javax.swing.JTextArea correctAnswerText;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel questionLabel;
    private javax.swing.JTextArea questionText;
    // End of variables declaration//GEN-END:variables

}
